// components/custom-tabbar/index.js
Component({
  options: {
    styleIsolation: 'isolated',
    addGlobalClass: true,
  },
  /**
   * 组件的属性列表
   */
  properties: {
    activeId: {
      type: Number,
      value: 1,
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    tabbarMenuList: [{
        id: 1,
        text: '首页',
        className: 'tabbar-item',
        iconPath: 'https://dycd.oss-cn-hangzhou.aliyuncs.com/266.png',
        selectedIconPath: 'https://dycd.oss-cn-hangzhou.aliyuncs.com/267.png',
        type: 'plain',
        pagePath: '/pages/home/home',
      },
      // {
      //   id: 2,
      //   text: '地图',
      //   className: 'tabbar-item',
      //   iconPath: '../../assets/images/map.png',
      //   selectedIconPath: '../../assets/images/map-fill.png',
      //   type: 'plain',
      //   pagePath: '/pages/map/map',
      // },
      {
        id: 3,
        text: '扫码',
        className: 'tabbar-item-bulge',
        iconPath: 'https://dycd.oss-cn-hangzhou.aliyuncs.com/268.png',
        selectedIconPath: 'https://dycd.oss-cn-hangzhou.aliyuncs.com/268.png',
        type: 'hump',
        pagePath: '/pages/charge/charge',
      },
      // {
      //   id: 4,
      //   text: '订单',
      //   className: 'tabbar-item',
      //   iconPath: '../../assets/images/order.png',
      //   selectedIconPath: '../../assets/images/order-fill.png',
      //   type: 'plain',
      //   pagePath: '/pages/myOrder/myOrder',
      // },
      {
        id: 5,
        text: '我的',
        className: 'tabbar-item',
        iconPath: 'https://dycd.oss-cn-hangzhou.aliyuncs.com/269.png',
        selectedIconPath: 'https://dycd.oss-cn-hangzhou.aliyuncs.com/270.png',
        type: 'plain',
        pagePath: '/pages/my/my',
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //选择tabbar
    onSelectTabber(event) {
      console.log(event);
      const {
        item
      } = event.currentTarget.dataset;
      console.log(item);
      if (item.pagePath) {
        let url = item.pagePath
        if (item.type == 'hump') {
          wx.navigateTo({
            url,
            success: function (res) {},
          })
        } else {
          wx.reLaunch({
            url,
            success: function (res) {},
          })
        }
      }
    }
  }
})